import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () => import('@/views/home/index'),
        name: 'Home',
        meta: { title: '首页', icon: 'home', affix: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: '个人中心', icon: 'user', noCache: true }
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/organization',
    component: Layout,
    redirect: '/organization/organization',
    alwaysShow: true,
    name: 'Organization',
    meta: {
      title: '组织管理',
      icon: 'organization',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'organization',
        component: () => import('@/views/Organization/OrganizationMain'),
        name: 'OrganizationMain',
        meta: {
          title: '组织管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-organization',
        component: () => import('@/views/UserOrganization/UserOrganizationMain'),
        name: 'UserOrganizationMain',
        meta: {
          title: '用户组织管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/user',
    alwaysShow: true,
    name: 'User',
    meta: {
      title: '用户管理',
      icon: 'user',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'user',
        component: () => import('@/views/User/UserMain'),
        name: 'UserMain',
        meta: {
          title: '用户基础信息管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-detail',
        component: () => import('@/views/UserDetail/UserDetailMain'),
        name: 'UserDetailMain',
        meta: {
          title: '用户详情管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-social',
        component: () => import('@/views/UserSocial/UserSocialMain'),
        name: 'UserSocialMain',
        meta: {
          title: '用户第三方登录管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-certification',
        component: () => import('@/views/UserCertification/UserCertificationMain'),
        name: 'UserCertificationMain',
        meta: {
          title: '用户实名认证管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-personal-setting',
        component: () => import('@/views/UserPersonalSetting/UserPersonalSettingMain'),
        name: 'UserPersonalSettingMain',
        meta: {
          title: '用户个性化管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'shipping-address',
        component: () => import('@/views/ShippingAddress/ShippingAddressMain'),
        name: 'ShippingAddressMain',
        meta: {
          title: '用户收货地址管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-role',
        component: () => import('@/views/UserRole/UserRoleMain'),
        name: 'UserRoleMain',
        meta: {
          title: '用户角色管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {

    path: '/platform-account',
    component: Layout,
    redirect: '/platform-account/platform-account-detail',
    alwaysShow: true,
    name: 'PlatformAccount',
    meta: {
      title: '平台资金管理',
      icon: 'money',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'platform-account-detail',
        component: () => import('@/views/PlatformAccountDetail/PlatformAccountDetailMain'),
        name: 'PlatformAccountDetailMain',
        meta: {
          title: '平台账目详情管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-account-detail',
        component: () => import('@/views/AccountDetail/AccountDetailMain'),
        name: 'AccountDetailMain',
        meta: {
          title: '用户账目详情管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {

    path: '/user-fund',
    component: Layout,
    redirect: '/user-fund/user-accountdetail',
    alwaysShow: true,
    name: 'UserFund',
    meta: {
      title: '用户资金管理',
      icon: 'money',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'user-backcard',
        component: () => import('@/views/UserBankcard/UserBankcardMain'),
        name: 'UserBankcardMain',
        meta: {
          title: '用户银行卡管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-wallet',
        component: () => import('@/views/UserWallet/UserWalletMain'),
        name: 'UserWalletMain',
        meta: {
          title: '用户钱包管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-account-detail',
        component: () => import('@/views/AccountDetail/AccountDetailMain'),
        name: 'AccountDetailMain',
        meta: {
          title: '账目详情管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'funds-recharge',
        component: () => import('@/views/FundsRecharge/FundsRechargeMain'),
        name: 'FundsRechargeMain',
        meta: {
          title: '充值管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'funds-transfer',
        component: () => import('@/views/FundsTransfer/FundsTransferMain'),
        name: 'FundsTransferMain',
        meta: {
          title: '转账管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'funds-frezee',
        component: () => import('@/views/FundsFrezee/FundsFrezeeMain'),
        name: 'FundsFrezeeMain',
        meta: {
          title: '冻结管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'funds-withdraw',
        component: () => import('@/views/FundsWithdraw/FundsWithdrawMain'),
        name: 'FundsWithdrawMain',
        meta: {
          title: '提现管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'funds-withdraw-check',
        component: () => import('@/views/FundsWithdrawCheck/FundsWithdrawCheckMain'),
        name: 'FundsWithdrawCheckMain',
        meta: {
          title: '提现审核历史管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
    ]
  },
  {
    path: '/user-opt',
    component: Layout,
    redirect: '/user-opt/sys-log',
    alwaysShow: true,
    name: 'UserOpt',
    meta: {
      title: '用户行为管理',
      icon: 'behave',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'sys-log',
        component: () => import('@/views/SysLog/SysLogMain'),
        name: 'SysLogMain',
        meta: {
          title: '业务日志管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'search-history',
        component: () => import('@/views/SearchHistory/SearchHistoryMain'),
        name: 'SearchHistoryMain',
        meta: {
          title: '搜索历史管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/ad-manage',
    component: Layout,
    redirect: '/ad-manage/advertisement-type',
    alwaysShow: true,
    name: 'AdManage',
    meta: {
      title: '广告管理',
      icon: 'ad',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'advertisement-type',
        component: () => import('@/views/AdvertisementType/AdvertisementTypeMain'),
        name: 'AdvertisementTypeMain',
        meta: {
          title: '广告类型管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'advertisement',
        component: () => import('@/views/Advertisement/AdvertisementMain'),
        name: 'AdvertisementMain',
        meta: {
          title: '广告管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/cms-management',
    component: Layout,
    redirect: '/cms-management/article-category',
    alwaysShow: true,
    name: 'CmsManagement',
    meta: {
      title: '内容管理',
      icon: 'content',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'article-category',
        component: () => import('@/views/ArticleCategory/ArticleCategoryMain'),
        name: 'ArticleCategoryMain',
        meta: {
          title: '文章类型管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'article',
        component: () => import('@/views/Article/ArticleMain'),
        name: 'ArticleMain',
        meta: {
          title: '文章管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'article-comment',
        component: () => import('@/views/ArticleComment/ArticleCommentMain'),
        name: 'ArticleComment',
        meta: {
          title: '文章评论管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/mall',
    component: Layout,
    redirect: '/mall/goods-basic',
    alwaysShow: true,
    name: 'Mall',
    meta: {
      title: '商城管理',
      icon: 'cart',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'basic',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Basic',
        alwaysShow: true,
        redirect: '/mall/basic/goods-brand',
        meta: {
          title: '基础信息管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-brand',
            component: () => import('@/views/GoodsBrand/GoodsBrandMain'),
            name: 'GoodsBrandMain',
            meta: {
              title: '商品品牌管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-attribute',
            component: () => import('@/views/GoodsAttribute/GoodsAttributeMain'),
            name: 'GoodsAttributeMain',
            meta: {
              title: '商品属性管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-category',
            component: () => import('@/views/GoodsCategory/GoodsCategoryMain'),
            name: 'GoodsCategoryMain',
            meta: {
              title: '商品类目管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-category-brand',
            component: () => import('@/views/GoodsCategoryBrand/GoodsCategoryBrandMain'),
            name: 'GoodsCategoryBrandMain',
            meta: {
              title: '类目品牌管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-category-attribute',
            component: () => import('@/views/GoodsCategoryAttribute/GoodsCategoryAttributeMain'),
            name: 'GoodsCategoryAttributeMain',
            meta: {
              title: '类目属性管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          }
        ]
      },
      {
        path: 'shop',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Shop',
        alwaysShow: true,
        redirect: '/mall/shop/goods-shop',
        meta: {
          title: '店铺管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-shop',
            component: () => import('@/views/GoodsShop/GoodsShopMain'),
            name: 'GoodsShopMain',
            meta: {
              title: '店铺管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-shop-certification', 
            component: () => import('@/views/GoodsShopCertification/GoodsShopCertificationMain'),
            name: 'GoodsShopCertificationMain',
            meta: {
              title: '店铺认证管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-shop-pickup-station', 
            component: () => import('@/views/GoodsShopPickupStation/GoodsShopPickupStationMain'),
            name: 'GoodsShopPickupStationMain',
            meta: {
              title: '店铺自提点管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
        ]
      },
      {
        path: 'express',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Express',
        alwaysShow: true,
        redirect: '/mall/express/express-template',
        meta: {
          title: '运费管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'express-template',
            component: () => import('@/views/ExpressTemplate/ExpressTemplateMain'),
            name: 'ExpressTemplateMain',
            meta: {
              title: '运费模板管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'express-template-item',
            component: () => import('@/views/ExpressTemplateItem/ExpressTemplateItemMain'),
            name: 'ExpressTemplateItemMain',
            meta: {
              title: '运费模板项管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
        ]
      },
      {
        path: 'goods',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Goods',
        alwaysShow: true,
        redirect: '/mall/goods/goods-info',
        meta: {
          title: '商品管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-info',
            component: () => import('@/views/GoodsInfo/GoodsInfoMain'),
            name: 'GoodsInfoMain',
            meta: {
              title: '商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-sku',
            component: () => import('@/views/GoodsSku/GoodsSkuMain'),
            name: 'GoodsSkuMain',
            meta: {
              title: '商品SKU管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-attribute-value',
            component: () => import('@/views/GoodsAttributeValue/GoodsAttributeValueMain'),
            name: 'GoodsAttributeValueMain',
            meta: {
              title: '商品SKU属性管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-pic',
            component: () => import('@/views/GoodsPic/GoodsPicMain'),
            name: 'GoodsPicMain',
            meta: {
              title: '商品图片管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-express',
            component: () => import('@/views/GoodsExpress/GoodsExpressMain'),
            name: 'GoodsExpressMain',
            meta: {
              title: '商品运费模板管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-commission',
            component: () => import('@/views/GoodsCommission/GoodsCommissionMain'),
            name: 'GoodsCommissionMain',
            meta: {
              title: '商品佣金管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          }
        ]
      },
      {
        path: 'goods-activity',
        component: () => import('@/views/nested/menu2/index'),
        name: 'GoodsActivity',
        alwaysShow: true,
        redirect: '/mall/goods-activity/goods-hot',
        meta: {
          title: '商品活动管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-hot',
            component: () => import('@/views/GoodsHot/GoodsHotMain'),
            name: 'GoodsHotMain',
            meta: {
              title: '热门商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-new',
            component: () => import('@/views/GoodsNew/GoodsNewMain'),
            name: 'GoodsNewMain',
            meta: {
              title: '新品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-agent',
            component: () => import('@/views/GoodsAgent/GoodsAgentMain'),
            name: 'GoodsAgentMain',
            meta: {
              title: '代理商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-seckill',
            component: () => import('@/views/GoodsSeckill/GoodsSeckillMain'),
            name: 'GoodsSeckillMain',
            meta: {
              title: '秒杀商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-groupon',
            component: () => import('@/views/GoodsGroupon/GoodsGrouponMain'),
            name: 'GoodsGrouponMain',
            meta: {
              title: '拼团商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-promotion',
            component: () => import('@/views/GoodsPromotion/GoodsPromotionMain'),
            name: 'GoodsPromotionMain',
            meta: {
              title: '促销商品管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          }
        ]
      },
      {
        path: 'coupon',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Coupon',
        alwaysShow: true,
        redirect: '/mall/coupon/goods-coupon',
        meta: {
          title: '优惠券管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-coupon',
            component: () => import('@/views/GoodsCoupon/GoodsCouponMain'),
            name: 'GoodsCouponMain',
            meta: {
              title: '优惠券管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-user-coupon',
            component: () => import('@/views/GoodsUserCoupon/GoodsUserCouponMain'),
            name: 'GoodsUserCouponMain',
            meta: {
              title: '用户优惠券管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          }
        ]
      },
      {
        path: 'cart',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Cart',
        alwaysShow: true,
        redirect: '/mall/cart/goods-cart',
        meta: {
          title: '购物车管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-cart',
            component: () => import('@/views/GoodsCart/GoodsCartMain'),
            name: 'GoodsCartMain',
            meta: {
              title: '购物车管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          }
        ]
      },
      {
        path: 'order',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Order',
        alwaysShow: true,
        redirect: '/mall/order/goods-order',
        meta: {
          title: '订单管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-order',
            component: () => import('@/views/GoodsOrder/GoodsOrderMain'),
            name: 'GoodsOrderMain',
            meta: {
              title: '订单管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-item',
            component: () => import('@/views/GoodsOrderItem/GoodsOrderItemMain'),
            name: 'GoodsOrderItemMain',
            meta: {
              title: '订单项管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-account',
            component: () => import('@/views/GoodsOrderAccount/GoodsOrderAccountMain'),
            name: 'GoodsOrderAccountMain',
            meta: {
              title: '订单账目管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-account-detail',
            component: () => import('@/views/GoodsOrderAccountDetail/GoodsOrderAccountDetailMain'),
            name: 'GoodsOrderAccountDetailMain',
            meta: {
              title: '订单账目详情管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-logistics',
            component: () => import('@/views/GoodsOrderLogistics/GoodsOrderLogisticsMain'),
            name: 'GoodsOrderLogisticsMain',
            meta: {
              title: '订单物流管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-coupon',
            component: () => import('@/views/GoodsOrderCoupon/GoodsOrderCouponMain'),
            name: 'GoodsOrderCouponMain',
            meta: {
              title: '订单优惠券管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-pickup-station',
            component: () => import('@/views/GoodsOrderPickupStation/GoodsOrderPickupStationMain'),
            name: 'GoodsOrderPickupStationMain',
            meta: {
              title: '订单自提点管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-refund',
            component: () => import('@/views/GoodsOrderRefund/GoodsOrderRefundMain'),
            name: 'GoodsOrderRefundMain',
            meta: {
              title: '退款管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-order-refund-pic',
            component: () => import('@/views/GoodsOrderRefundPic/GoodsOrderRefundPicMain'),
            name: 'GoodsOrderRefundPicMain',
            meta: {
              title: '退款图片管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
        ]
      },
      {
        path: 'comment',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Comment',
        alwaysShow: true,
        redirect: '/mall/comment/goods-comment',
        meta: {
          title: '评论与收藏管理',
          roles: ['super_sys_admin', 'sys_admin']
        },
        children: [
          {
            path: 'goods-comment',
            component: () => import('@/views/GoodsComment/GoodsCommentMain'),
            name: 'GoodsCommentMain',
            meta: {
              title: '商品评论管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-comment-pic',
            component: () => import('@/views/GoodsCommentPic/GoodsCommentPicMain'),
            name: 'GoodsCommentPicMain',
            meta: {
              title: '商品评论图片管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
          {
            path: 'goods-collection',
            component: () => import('@/views/GoodsCollection/GoodsCollectionMain'),
            name: 'GoodsCollectionMain',
            meta: {
              title: '商品收藏管理',
              roles: ['super_sys_admin', 'sys_admin']
            }
          },
        ]
      }
    ]
  },
  {
    path: '/distribution',
    component: Layout,
    redirect: '/distribution/user-hierarchy',
    alwaysShow: true,
    name: 'Distritution',
    meta: {
      title: '分销管理',
      icon: 'distribution',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'user-hierarchy',
        component: () => import('@/views/UserHierarchy/UserHierarchyMain'),
        name: 'UserHierarchyMain',
        meta: {
          title: '用户层级关系管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-path',
        component: () => import('@/views/UserPath/UserPathMain'),
        name: 'UserPathMain',
        meta: {
          title: '用户路径管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
    ]
  },
  {
    path: '/processes',
    component: Layout,
    redirect: '/processes/statistics-dau',
    alwaysShow: true,
    name: 'Processes',
    meta: {
      title: '流程管理',
      icon: 'process',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'process',
        component: () => import('@/views/Process/ProcessMain'),
        name: 'ProcessMain',
        meta: {
          title: '流程文件管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/data-report',
    component: Layout,
    redirect: '/data-report/statistics-dau',
    alwaysShow: true,
    name: 'DataReport',
    meta: {
      title: '数据报表管理',
      icon: 'chart',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'statistics-dau',
        component: () => import('@/views/StatisticsDau/StatisticsDauMain'),
        name: 'StatisticsDauMain',
        meta: {
          title: '每日活跃用户统计',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'dau-report',
        component: () => import('@/views/report/DauReport'),
        name: 'DauReport',
        meta: {
          title: 'DAU统计报表',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'account-report',
        component: () => import('@/views/report/AccountReport'),
        name: 'AccountReport',
        meta: {
          title: '平台出入账统计报表',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'order-report',
        component: () => import('@/views/report/OrderReport'),
        name: 'OrderReport',
        meta: {
          title: '商城订单统计报表',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {

    path: '/sys-content',
    component: Layout,
    redirect: '/sys-content/sys-config',
    alwaysShow: true,
    name: 'SysContent',
    meta: {
      title: '系统内容管理',
      icon: 'setting',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'sys-config',
        component: () => import('@/views/SysConfig/SysConfigMain'),
        name: 'SysConfigMain',
        meta: {
          title: '系统配置管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'notice',
        component: () => import('@/views/Notice/NoticeMain'),
        name: 'NoticeMain',
        meta: {
          title: '公告管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'message',
        component: () => import('@/views/Message/MessageMain'),
        name: 'MessageMain',
        meta: {
          title: '消息管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'user-message',
        component: () => import('@/views/UserMessage/UserMessageMain'),
        name: 'UserMessageMain',
        meta: {
          title: '用户消息管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'suggestion',
        component: () => import('@/views/Suggestion/SuggestionMain'),
        name: 'SuggestionMain',
        meta: {
          title: '投诉建议管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/data-dict',
    component: Layout,
    redirect: '/data-dict/dict',
    alwaysShow: true,
    name: 'DataDict',
    meta: {
      title: '数据字典管理',
      icon: 'dict',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'dict',
        component: () => import('@/views/DataDict/DataDictMain'),
        name: 'DataDictMain',
        meta: {
          title: '数据字典管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'dict-item',
        component: () => import('@/views/DataDictItem/DataDictItemMain'),
        name: 'DataDictItemMain',
        meta: {
          title: '数据字典项管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/sys-menu',
    component: Layout,
    redirect: '/sys-menu/sys-menu',
    alwaysShow: true,
    name: 'SysMemu',
    meta: {
      title: '系统菜单管理',
      icon: 'menu',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'sys-menu',
        component: () => import('@/views/SysMenu/SysMenuMain'),
        name: 'SysMenuMain',
        meta: {
          title: '系统菜单管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'role-menu',
        component: () => import('@/views/RoleMenu/RoleMenuMain'),
        name: 'RoleMenuMain',
        meta: {
          title: '角色菜单管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/sys-security',
    component: Layout,
    redirect: '/sys-security/app-auth',
    alwaysShow: true,
    name: 'SysSecurity',
    meta: {
      title: '系统安全管理',
      icon: 'security',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'app-auth',
        component: () => import('@/views/AppAuth/AppAuthMain'),
        name: 'AppAuthMain',
        meta: {
          title: '应用授权管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'role',
        component: () => import('@/views/Role/RoleMain'),
        name: 'RoleMain',
        meta: {
          title: '角色管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'module',
        component: () => import('@/views/Module/ModuleMain'),
        name: 'ModuleMain',
        meta: {
          title: '模块管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'permission',
        component: () => import('@/views/Permission/PermissionMain'),
        name: 'PermissionMain',
        meta: {
          title: '权限管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'role-permission',
        component: () => import('@/views/RolePermission/RolePermissionMain'),
        name: 'RolePermissionMain',
        meta: {
          title: '角色权限管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  {
    path: '/sys-monitor',
    component: Layout,
    redirect: '/sys-monitor/scheduler',
    alwaysShow: true,
    name: 'SysMonitor',
    meta: {
      title: '系统监控管理',
      icon: 'monitor',
      roles: ['super_sys_admin', 'sys_admin']
    },
    children: [
      {
        path: 'scheduler',
        component: () => import('@/views/Scheduler/SchedulerMain'),
        name: 'SchedulerMain',
        meta: {
          title: '定时任务管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      },
      {
        path: 'redis',
        component: () => import('@/views/RedisCache/RedisCache'),
        name: 'RedisCache',
        meta: {
          title: 'Redis缓存管理',
          roles: ['super_sys_admin', 'sys_admin']
        }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
